package gui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Composite;


public class NewProject {

	protected Shell shlNewProject;
	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_3;
	private Button btnDiagramEditor;

	/**
	 * Launch the application.
	 * @param args
	 */
//	public static void main(String[] args) {
//		try {
//		//	NewProject window = new NewProject();
//		//	window.open();
//			GUIManager.getDefault().newproject.open();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shlNewProject.open();
		shlNewProject.layout();
		while (!shlNewProject.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shlNewProject = new Shell();
		shlNewProject.setSize(430, 398);
		shlNewProject.setText("New Project");
		
		Label lblProjectName = new Label(shlNewProject, SWT.NONE);
		lblProjectName.setBounds(22, 30, 78, 15);
		lblProjectName.setText("Project Name");
		
		Label lblSaveIn = new Label(shlNewProject, SWT.NONE);
		lblSaveIn.setBounds(22, 57, 55, 15);
		lblSaveIn.setText("Save in");
		
		text = new Text(shlNewProject, SWT.BORDER);
		text.setBounds(109, 27, 153, 21);
		
		text_1 = new Text(shlNewProject, SWT.BORDER);
		text_1.setBounds(109, 54, 153, 21);
		
		Button btnBrowse = new Button(shlNewProject, SWT.NONE);
		btnBrowse.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnBrowse.setBounds(279, 52, 75, 25);
		btnBrowse.setText("Browse");
		
		Group grpConversion = new Group(shlNewProject, SWT.NONE);
		grpConversion.setText("Conversion");
		grpConversion.setBounds(22, 93, 353, 220);
		
		Button btnCodeToUml = new Button(grpConversion, SWT.RADIO);
		btnCodeToUml.setBounds(10, 34, 90, 16);
		btnCodeToUml.setText("Code to UML");
		
		Button btnUmlToCode = new Button(grpConversion, SWT.RADIO);
		btnUmlToCode.setBounds(10, 95, 90, 16);
		btnUmlToCode.setText("UML to Code");
		
		Label lblOpenFile = new Label(grpConversion, SWT.NONE);
		lblOpenFile.setBounds(30, 56, 55, 15);
		lblOpenFile.setText("Open File");
		
		text_2 = new Text(grpConversion, SWT.BORDER);
		text_2.setBounds(91, 56, 145, 21);
		
		Button btnBrowse_1 = new Button(grpConversion, SWT.NONE);
		btnBrowse_1.setBounds(257, 51, 75, 25);
		btnBrowse_1.setText("Browse");
		
		Composite composite = new Composite(grpConversion, SWT.NONE);
		composite.setBounds(10, 117, 333, 85);
		
		Button button = new Button(composite, SWT.RADIO);
		button.setText("Open File");
		button.setBounds(10, 12, 67, 16);
		
		text_3 = new Text(composite, SWT.BORDER);
		text_3.setBounds(83, 12, 145, 21);
		
		Button button_2 = new Button(composite, SWT.NONE);
		button_2.setText("Browse");
		button_2.setBounds(248, 10, 75, 25);
		
		btnDiagramEditor = new Button(composite, SWT.NONE);
		btnDiagramEditor.setBounds(10, 50, 91, 25);
		btnDiagramEditor.setText("Diagram Editor");
		btnDiagramEditor.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				// TODO Auto-generated method stub
				
			//	DiagramEditor diagramEditor = new DiagramEditor(Display.getDefault());
			//	diagramEditor.open();
				GUIManager.getDefault().diagram.openEditor();
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		
		Button btnOk = new Button(shlNewProject, SWT.NONE);
		btnOk.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shlNewProject.dispose();
			}
		});
		btnOk.setBounds(244, 326, 75, 25);
		btnOk.setText("Ok");
		
		Button btnCancel = new Button(shlNewProject, SWT.NONE);
		btnCancel.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shlNewProject.dispose();
			}
		});
		btnCancel.setBounds(329, 326, 75, 25);
		btnCancel.setText("Cancel");

	}
}
